/*
 * Author: James Harpe
 *
 *   Copyright © 2014 Allen County Public Library.

  ACPL Mobile is free software: This program is distributed and you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.  ACPL Mobile is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, including without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with ACPL Mobile. If not, see http://www.gnu.org/licenses/.
 * 
 * Description: This adapter is responsible for the layout and content of the locations in the 
 * 				EventMainActivity.
 */

package us.in.lib.acpl.Mobile_ACPL.adapters;

import us.in.lib.acpl.Mobile_ACPL.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class EventMainAdapter extends ArrayAdapter<String> {

	String[] values;
	Context context;

	public EventMainAdapter(Context context, String[] objects) {
		super(context, R.layout.event_main_list_item, objects);

		this.values = objects;
		this.context = context;

	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowView = inflater.inflate(R.layout.event_main_list_item, parent,
				false);

		String loc = values[position];
		if (loc.equalsIgnoreCase("All")) {
			loc = loc + " Events";
		} else if (loc.equalsIgnoreCase("Main")) {
			loc = loc + " Library";
		}else if (loc.equalsIgnoreCase("Childrens")){
			loc = "Main - Children's Services";
		}
		TextView t = (TextView) rowView.findViewById(R.id.eventBranchText);
		t.setText(loc);

		return rowView;
	}
}
